﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using eCitizen.eAlerts.Constants;
using eCitizen.DataContracts;
using eCitizen.DataAccess;
using eCitizen.eAlerts.Utilities;

namespace eCitizen.eAlerts.BusinessService
{
    public class StopWatchHelper
    {
        protected int _batchInstanceId;
        protected int _batchServiceInstanceId;
        protected BatchJobLoggingService _batchJobLoggingService;

        public StopWatchHelper()
        {
            _batchJobLoggingService = new BatchJobLoggingService();
        }

        public void StartBatchJobWatch(ServiceType currentServiceType)
        {
            int serviceType = (int)currentServiceType;
            _batchInstanceId = _batchJobLoggingService.StartBatchJobWatch(serviceType, DateTime.Now);
        }
        public void StopBatchJobWatch()
        {
            _batchJobLoggingService.StopBatchJobWatch(_batchInstanceId, DateTime.Now);
        }

        public void StartServiceInstanceWatch(SftpConfiguration currentConfig)
        {
            _batchServiceInstanceId = _batchJobLoggingService.StartServiceInstanceWatch(_batchInstanceId, currentConfig.Agency, currentConfig.Service, DateTime.Now);
        }

        public void StopServiceInstanceWatch(SftpConfiguration currentConfig)
        {
            _batchJobLoggingService.StopServiceInstanceWatch(_batchServiceInstanceId, DateTime.Now);
        }

        public List<RequestEntry> LogAlertServiceRequests(List<RequestEntry> subscriptionRequest)
        {
            return _batchJobLoggingService.LogAlertServiceRequests(_batchServiceInstanceId, subscriptionRequest);
        }

        public void LogSubscribersForBroadcast(List<Subscriber> subscriberList)
        {
            _batchJobLoggingService.LogSubscribersForBroadcast(_batchServiceInstanceId, subscriberList);
        }
    }
}
